package com.portal.business.show;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.portal.business.functions.dao.FunctionsDao;
import com.portal.business.functions.dto.FunctionsDTO;
import com.portal.business.show.dao.ShowLogDao;
import com.portal.business.show.dto.ShowLogDTO;
import com.portal.business.show.dto.ShowLogResultBean;
import com.portal.framework.common.PortalSearchBean;
import com.portal.framework.page.Pager;


	
/**
 * 
 * 项目名称: Portal     
 * 类名称:   ShowServiceImpl     
 * 类描述:   演示搜索日志 
 * 创建人:   骆海东
 * 创建时间: Aug 31, 2011 3:13:05 PM     
 * 最后修改人:   骆海东
 * 最后修改时间: Aug 31, 2011 3:13:05 PM     
 * 最后修改备注:
 */
public class ShowServiceImpl implements ShowService {

	private ShowLogDao showLogDao;
	
	
	public Boolean addShowLog(ShowLogDTO showLogDTO) {
		if(this.showLogDao.create(showLogDTO)!=null)return true;
		else return false;
	}

	public int delShowLog(Integer showLogId) {
		return this.showLogDao.delete(showLogId);
	}

	public int delShowLogBatch(String[] asIdsStr) {
		int len=asIdsStr.length;
		Integer[] ids=new Integer[len];
		for (int i = 0; i <len; i++) {
			ids[i]=Integer.valueOf(asIdsStr[i]);
		}
		return this.showLogDao.deleteBatch(ids);
	}

	public ShowLogDTO findByID(Integer ShowLogId) {
		ShowLogDTO p= this.showLogDao.findById(ShowLogId);
		return p;
	}

	public ShowLogResultBean findShowLog(PortalSearchBean portalSearchBean) {

		String selecthql=" ";//查数据hql
		String countHql="select count(logId)";//查总数hql
		String hql=" from ShowLogDTO ";//条件hql
		//用于保存查找输入参数集合
		List<Object> osList=new ArrayList<Object>();
		if(portalSearchBean.getName()!=null&&!portalSearchBean.getName().trim().equals("")){
			hql=hql+"where name like ?";
			osList.add("%"+portalSearchBean.getName()+"%");
		}
		hql=hql+" order by logId desc";
		//获取总数
		int count=this.showLogDao.countQuery(countHql+hql,osList.toArray());
		//设置页码对象
		Pager pager=new Pager();
		pager.setPageSize(portalSearchBean.getPageSize());
		pager.setTotal(count);
		pager.setCurrentPage(portalSearchBean.getPage());
		//获取数据
		List<ShowLogDTO> olsit=this.showLogDao.find(pager.getStart(),pager.getPageSize(), ShowLogDTO.class,selecthql+hql, osList.toArray());
		//设置返回对象
		ShowLogResultBean pb=new ShowLogResultBean();
		pb.setCount(count);
		pb.setResultList(olsit);
		return pb;
	}

	public ShowLogDao getShowLogDao() {
		return showLogDao;
	}

	public void setShowLogDao(ShowLogDao showLogDao) {
		this.showLogDao = showLogDao;
	}

}

		